<template>
	<view class="content b-t">
		<None v-if="list_empty"></None>
		<view class="list b-b" v-for="(item, index) in accounts" :key="index" v-else>
			<view class="wrapper">
				<view class="address-box">
				
					<text  class="tag">{{item.type}}</text>
					<text class="address">{{item.name}}</text>
				</view>
				<view class="u-box">
					
					<text class="mobile">{{item.ispic == 1 ? '详情查看图片' : item.accounts}}</text>
				</view>
			</view>
			<text class="yticon icon-bianji" @click.stop="addAddress('edit', item)"></text>
		</view>
		<!-- <text style="display:block;padding: 16upx 30upx 10upx;lihe-height: 1.6;color: #fa436a;font-size: 24upx;">
			重要：添加和修改地址回调仅增加了一条数据做演示，实际开发中将回调改为请求后端接口刷新一下列表即可
		</text> -->
		<view class="add-btn">
			<button style="background-color:#52a5f7;width: 45%; color: #fff;"   @click="addAddressA('add')">&emsp;新增地址</button>
		</view>


	</view>
</template>

<script>
	import None from "@/components/qy/none.vue"
	export default {
		data() {
			return {
				list_empty: false,
				form: {
					name: '',
					type: '',
					accounts: '',
					picurl: '',
					ispic: 1,
					id: 0
				},
		
				source: 0,
				accounts: [],
				type_add: 'add'
			}
		},
		components:{
			None
		},
		onLoad(option) {
			this.source = option.source;
		
		},
		onShow() {
				this._load()
		},
		methods: {
		
			
			_load() {
				this.$api.http.get('/assistance/accounts/getUserAccounts').then(res => {
					if (res.data=='') {
						this.list_empty = true
					} else {
						this.list_empty = false
						this.accounts = res.data
					}
				})
			},
			
			addAddress(type, item) {
				uni.setStorageSync('edit_data', item)
				uni.navigateTo({
					url: `/pages/bussiness/accountsManage?type=` + type
				})
			},
			addAddressA() {
				uni.navigateTo({
					url: `/pages/bussiness/accountsManage?type=` + this.type_add
				})
			},
			
		},
		onPullDownRefresh() {
			this._load()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 2000);
		}
	}
</script>

<style lang='scss'>
	page {
		padding-bottom: 120upx;
    background-color: $bg-gap;
	}

	.content {
		position: relative;
	}

	.list {
		display: flex;
		align-items: center;
		padding: 20upx 30upx;
		;
		background: $bg-theme;
		position: relative;
	}

	.wrapper {
		display: flex;
		flex-direction: column;
		flex: 1;
	}

	.address-box {
		display: flex;
		align-items: center;

		.tag {
			font-size: 24upx;
			width:auto;
			color: $base-color;
			margin-right: 10upx;
			background: #fffafb;
			border: 1px solid #ffb4c7;
			border-radius: 4upx;
			padding: 4upx 10upx;
			line-height: 1;
			text-align: center;
		}

		.address {
			font-size: 30upx;
			color: $text-color;
		}
	}

	.u-box {
		font-size: 28upx;
		color: $font-color-light;
		margin-top: 16upx;

		.name {
			margin-right: 30upx;
		}
	}

	.icon-bianji {
		display: flex;
		align-items: center;
		height: 80upx;
		font-size: 40upx;
		color: $font-color-light;
		padding-left: 30upx;
	}

	.add-btn {
		position: fixed;
		left: 30upx;
		right: 30upx;
		bottom: 16upx;
		z-index: 95;
		display: flex;
		align-items: center;
		justify-content: center;
		width: 690upx;
		height: 80upx;
		font-size: 32upx;
		color: #fff;

		border-radius: 10upx;

	}
</style>
